<?php
class ReservasForm extends sfForm
{
  public function configure()
  {
    $cantidades = array(1 => 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
    $this->setWidgets(array(
      'nombre'              => new sfWidgetFormInputText(),
      'pais'                => new sfWidgetFormInputText(),
      'email'               => new sfWidgetFormInputText(),
      'telefono'            => new sfWidgetFormInputText(),
      'fecha_arribo'        => new sfWidgetFormDateJQueryUI(array('change_month' => true, 'change_year'=> true),array('class' => 'date-picker left-input short-input', 'readonly' => 'readonly', 'placeholder' => 'Fecha de Arribo')),
      'fecha_salida'        => new sfWidgetFormDateJQueryUI(array('change_month' => true, 'change_year'=> true),array('class' => 'date-picker short-input', 'readonly' => 'readonly', 'placeholder' => 'Fecha de Salida')),
      'adultos'             => new sfWidgetFormInputText(array(),array('class' => 'number-picker left-input short-input')),
      'ninios'              => new sfWidgetFormInputText(array(),array('class' => 'number-picker short-input')),
      'consulta'            => new sfWidgetFormTextarea(array(),array('rows' => 10)),
    ));

    $this->setValidators(array(
      'nombre'              => new sfValidatorString(array('max_length' => 50, 'required' => true)),
      'pais'                => new sfValidatorString(array('max_length' => 50, 'required' => true)),
      'email'               => new sfValidatorString(array('max_length' => 150, 'required' => true)),
      'telefono'            => new sfValidatorString(array('max_length' => 150, 'required' => false)),
      'fecha_arribo'        => new sfValidatorString(array('required' => false)),
      'fecha_salida'        => new sfValidatorString(array('required' => false)),
      'adultos'             => new sfValidatorChoice(array('required' => true, 'choices' => $cantidades)),
      'ninios'              => new sfValidatorChoice(array('required' => true, 'choices' => $cantidades)),
      'consulta'            => new sfValidatorString(array('required' => false)),
    ));
    
    $this->widgetSchema->setLabels(array(
      'nombre'    => ' ',
      'pais'   => ' ',
      'email'   => ' ',
      'telefono'   => ' ',
      'fecha_arribo' => ' ',
      'fecha_salida' => ' ',
      'adultos' => ' ',
      'ninios' => ' ',
      'consulta' => ' ',
    ));
    $this->widgetSchema->setNameFormat('reservas[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->widgetSchema->setFormFormatterName('list');

    parent::setup();
  }
}
